package com.yfht.framework.context;

import org.springframework.context.ApplicationContext;

public class Ctx {
	  private static ApplicationContext appContext = null;

	  public static ApplicationContext getAppContext() {
	    return appContext;
	  }

	  public static void setAppContext(ApplicationContext appContext) {
		  Ctx.appContext = appContext;
	  }

	  public static Object getBean(String beanName)
	  {
	    return appContext.getBean(beanName);
	  }

	  public static Object getBean(Class cls)
	  {
	    String classSimpleName = cls.getSimpleName();
	    classSimpleName = classSimpleName.substring(0, 1).toLowerCase() + classSimpleName.substring(1, classSimpleName.length());
	    return appContext.getBean(classSimpleName);
	  }
}
